package model

import (
	"gitee.com/xuxinzhi2206/corehub/database/mysql"
	"gorm.io/gorm"
)

// 积分表
type Integral struct {
	gorm.Model
	UserId        int64 `gorm:"type:int(11);unique;not null;用户id"`
	PointsBalance int64 `gorm:"type:int(11);default:0;comment:积分余额"`
}

// 查询用户积分详情
func (i *Integral) GetIntegralInfo(userId int64) (*Integral, error) {
	return i, mysql.WithMysql(func(db *gorm.DB) error {
		return db.Model(&i).Where("user_id = ?", userId).First(&i).Error
	})
}
